<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:pe="http://primefaces.org/ui/extensions">

    <h:body>

        <ui:composition template="/resources/template/template.xhtml">

            <ui:define name="content">
                <h:form>

                    <p:panel header="All Supplier Stock Report" >

                        <h:panelGrid columns="2" >
                            <h:outputLabel value="Department" ></h:outputLabel>
                            <p:autoComplete completeMethod="#{departmentController.completeDept}" 
                                            var="dept" itemLabel="#{dept.name}" itemValue="#{dept}" 
                                            forceSelection="true" value="#{storeReportsStock.department}" converter="departmentConverter" >
                            </p:autoComplete>
                            </h:panelGrid>
                        <h:panelGrid columns="4" >
                            <p:spacer width="80" height="1"/>
                            <p:commandButton ajax="false" value="Process" actionListener="#{storeReportsStock.fillAllDistributorStocks()}" ></p:commandButton>
                            <p:commandButton value="Print" ajax="false" >
                                <p:printer target="gpBillPreview" ></p:printer>
                            </p:commandButton>
                            <p:commandButton ajax="false" value="Excel" styleClass="noPrintButton" style="float: right;" >
                                <pe:exporter type="xlsx" target="tbl" fileName="Category_report"  />
                            </p:commandButton>
                        </h:panelGrid>

                        <h:panelGroup id="gpBillPreview">
                            <p:dataTable id="tbl" rowStyleClass="#{i.stock eq 0 ?'noDisplayRow' : ''}" value="#{storeReportsStock.records}" var="i"  >
                                <f:facet name="header">
                                    <h:outputLabel value="#{storeReportsStock.department.name} : All Suppliers' Stock"/>  
                                </f:facet>
                                
                                <p:column headerText="Supplier">
                                    <f:facet name="header">
                                        <h:outputLabel value="Supplier"/>
                                    </f:facet>
                                    <h:outputLabel value="#{i.institution.name}" ></h:outputLabel>
                                </p:column>
                                
                                <!--<p:column headerText="Code">
                                    <f:facet name="header">
                                        <h:outputLabel value="Code"/>
                                    </f:facet>
                                    <h:outputLabel value="#{i.itemBatch.item.code}" style="width: 100px!important;" ></h:outputLabel>
                                </p:column>-->
                                
                                <p:column headerText="Stock Quentity">
                                    <f:facet name="header">
                                        <h:outputLabel value="Stock Quantity"/>
                                    </f:facet>
                                    <h:outputLabel value="#{i.qty}"  >
                                        <f:convertNumber pattern="#,###" ></f:convertNumber>
                                    </h:outputLabel>
                                </p:column>
                                
                                <p:column headerText="Purchase Value" style="text-align: right;">
                                    <f:facet name="header">
                                        <h:outputLabel value="Purchase Value"/>
                                    </f:facet>
                                    <h:outputLabel value="#{i.purchaseValue}"  >
                                        <f:convertNumber pattern="#,##0.00" ></f:convertNumber>
                                    </h:outputLabel>
                                    <f:facet name="footer" >
                                        <h:outputLabel value="#{storeReportsStock.stockPurchaseValue}" >
                                            <f:convertNumber parent="#,##0.00" ></f:convertNumber>
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                                
                                <p:column headerText="Retail Sale Value" style="text-align: right;">
                                    <f:facet name="header">
                                        <h:outputLabel value="Retail Sale Value"/>
                                    </f:facet>
                                    <h:outputLabel value="#{i.retailsaleValue}"  >
                                        <f:convertNumber pattern="#,##0.00" ></f:convertNumber>
                                    </h:outputLabel>
                                    <f:facet name="footer" >
                                        <h:outputLabel value="#{storeReportsStock.stockSaleValue}" >
                                            <f:convertNumber parent="#,##0.00" ></f:convertNumber>
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                                <f:facet name="footer" >
                                    <h:outputLabel value="Printed By : #{sessionController.loggedUser.webUserPerson.name}" style="float: right"/>
                                </f:facet>

                            </p:dataTable>
                        </h:panelGroup>
                    </p:panel>
                </h:form>


            </ui:define>


        </ui:composition>

    </h:body>
</html>
